<%@page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<style type="text/css">
.labelTitle{
    margin-left: 30px;
    font-size: 18px;
    font-weight: 800;
    line-height: 20px;
}
.divTitle{
    margin-left: 40px;
    font-size: 16px;
    font-weight: 700;
    line-height: 35px;
}
table{
    margin-left: 45px;
}
tr{
   
}
td{
    width: 300px;
    margin-top: 10px;
    margin-bottom: 10px;
    line-height: 35px;
    text-align: center;
}
input{
    width: 100px;
    height: 30px;
    font-size: 17px;
    padding-left: 15px;
}
#test{
    margin-left: 400px;
    margin-top: 40px;
}
</style>
</head>
<body>
	<div class="linkbar"><a>监控平台</a>/<a>出入水阀值控制</a></div>
	<div class="clear"></div>
	<form id="waterAlarmConfigForm" method="post">
	 <div>
	    <label for="name" class="labelTitle">请设置出入水阀值:</label>
	</div>
	<div class="divTitle">
	入水阀值设置：
	</div>
	<table id="inwater">
	     <tr>
              <td>预警状态</td>
              <td>大于：</td>
              <td>~</td>
              <td>小于等于：</td>
              <td></td>
          </tr>
          <c:forEach items="${alarmConfigList}" var="p" varStatus="ind">
             <c:if test="${p.direction == '1'}"> 
             <input name="alarmConfigList[${ind.index}].direction" value="${p.direction}" type="hidden"/>
                <tr>
                      <td><span class="alarmNum">${p.alarmLevel}</span><input name="alarmConfigList[${ind.index}].alarmLevel" value="${p.alarmLevel}" type="hidden"/></td>
		              <td>
		                  <input type="text" name="alarmConfigList[${ind.index}].upperLimit" value="${p.upperLimit}">
		              </td>
		              <td>~</td>
		              <td>
		                  <input type="text" name="alarmConfigList[${ind.index}].lowerLimit" value="${p.lowerLimit}">
		              </td>
                </tr>
             </c:if>
          </c:forEach>
          
	</table>
	<div class="divTitle">
	出水阀值设置：
	</div> 
	<table id="outwater">
	     <tr>
              <td>预警状态</td>
              <td>大于：</td>
              <td>~</td>
              <td>小于等于：</td>
              <td></td>
          </tr>
          <c:forEach items="${alarmConfigList}" var="p" varStatus="ind">
             <c:if test="${p.direction == '2'}"> 
                <input name="alarmConfigList[${ind.index}].direction" value="${p.direction}" type="hidden"/>
                <tr>
                      <td><span class="alarmNum">${p.alarmLevel}</span><input name="alarmConfigList[${ind.index}].alarmLevel" value="${p.alarmLevel}" type="hidden"/></td>
		              <td>
		                  <input type="text" name="alarmConfigList[${ind.index}].upperLimit" value="${p.upperLimit}">
		              </td>
		              <td>~</td>
		              <td>
		                  <input type="text" name="alarmConfigList[${ind.index}].lowerLimit" value="${p.lowerLimit}">
		              </td>
                </tr>
             </c:if>
          </c:forEach>
	</table>

        <div id="test">
           <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitCommission()" style="width:100px;background: #9c9a98;">确定</a>
        </div>        
    </form>
	
	
	
	
	
	
	
	
	
	
	
	
	
	
<script type="text/javascript">
  $(document).ready(function() {
     var alarmLevelJson=syncGetDictListByTypeName('alarm_level');
	 $(".alarmNum").each(function(i){
	    for(i=0;i<alarmLevelJson.length;i++){
	      if($(this).text()==alarmLevelJson[i].dictValue){ 
		    $(this).text(alarmLevelJson[i].dictName);
		    break;
		  }
	    }
	    
	});
  });

   function submitCommission(){
	   $('#waterAlarmConfigForm').form('submit', {
	        url: 'rest/alarmConfigAdd.do',        
	        onSubmit: function () {
	        	/* if(!$("input[name='type']").val()){
	        	  $.messager.alert('操作提示', "优惠券类型不能为空", 'error');	
	        	  return false; 
	        	}
	        	if(!$("#produceMoney").val() || isNaN($("#produceMoney").val())){
	        	  $.messager.alert('操作提示', "优惠券金额不能为空或者字符串，只能为数字", 'error');	
	        	  return false; 
	        	}
	        	if(!$("#produceAmount").val() || isNaN($("#produceAmount").val())){
	        	  $.messager.alert('操作提示', "优惠券数量不能为空或者字符串，只能为数字", 'error');	
	        	  return false; 
	        	}
	        	var couponType = $("#overdueTime").datebox("getValue");
	        	if(!couponType){
	        	  $.messager.alert('操作提示', "优惠券截至日期不能为空", 'error');	
	        	  return false; 
	        	} */
	        },
	        success: function (result) {   
	            var aas = jQuery.parseJSON(result);
	        	if (aas.success == "true") {
					$.messager.alert('操作提示', "添加成功", 'info');							
				} else {
				   if(aas.retMsg){
				      $.messager.alert('操作提示', aas.retMsg, 'error');
				   }else{
				      $.messager.alert('操作提示', "添加失败", 'error');
				   }
				}
	        }
	    });
   
   }
</script>	
</body>
</html>